cmake_minimum_required(VERSION 2.8)

message("-- Project: stdcrt")

file(GLOB stdcrt_src "*.c")
file(GLOB stdcrt_code_src 			"code/*.c")
file(GLOB stdcrt_io_src 			"io/*.c")
file(GLOB stdcrt_msg_src 			"msg/*.c")
file(GLOB stdcrt_net_src 			"net/*.c")
file(GLOB stdcrt_stdlib_src 		"stdlib/*.c")
file(GLOB stdcrt_thread_src 		"thread/*.c")
file(GLOB stdcrt_string_src 		"string/*.c")
file(GLOB stdcrt_algorithm_src 		"algorithm/*.c")
file(GLOB stdcrt_init_src 			"init/*.c")


if (${UNIX_OS})
	include_directories(
		${PROJECT_SOURCE_DIR}/crt
		/usr/local/include
		/opt/local/include
		/usr/include
		)
	link_directories(/opt/local/lib)
elseif (${WIN_OS})

	include_directories(
		${PROJECT_SOURCE_DIR}/crt
		${by3rd_library_include})
	
else()

endif()


add_library(stdcrt  STATIC 	${stdcrt_src}
							${stdcrt_code_src} 
							${stdcrt_io_src}
							${stdcrt_msg_src}
							${stdcrt_net_src} 
							${stdcrt_stdlib_src} 
							${stdcrt_thread_src}
							${stdcrt_string_src}
							${stdcrt_algorithm_src}
							${stdcrt_init_src})
							


set_target_properties(stdcrt PROPERTIES OUTPUT_NAME "stdcrt")

if (CMAKE_SYSTEM_NAME MATCHES "Windows")

else()
	set_target_properties(stdcrt PROPERTIES COMPILE_FLAGS ${static})
	set_target_properties(stdcrt PROPERTIES COMPILE_FLAGS ${static_compile})
endif()


if (CMAKE_SYSTEM_NAME MATCHES "Android")
	target_link_libraries(stdcrt log)
	target_link_libraries(stdcrt dl)
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
	target_link_libraries(stdcrt dl pthread)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
    target_link_libraries(stdcrt pthread dl)
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
    target_link_libraries(stdcrt pthread dl)
elseif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
    target_link_libraries(stdcrt pthread dl)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
	
elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS")
     target_link_libraries(stdcrt pthread dl)
else()
	message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
endif()

















